export default
{
	template: `
	
	<div id="contain">
		<div id="table">
			<h3>课程管理系统</h3><hr/>
			<table>
				<thead>
					<th>ID</th>
					<th>课程名</th>
					<th>开始学期</th>
					<th>结束学期</th>
					<th>课时</th>
					<th>操作</th>
				</thead>
				<tr v-for="stu,i in study">
					<td>{{stu.id}}</td>
					<td>{{stu.name}}</td>
					<td>{{stu.grade}}</td>
					<td>{{stu.gradeEnd}}</td>
					<td>{{stu.time}}</td>
					<td id="action">
						<button @click="del(i)">删除</button>
						<button>修改</button>
					</td>
				</tr>
			</table>
			<hr/>
			<div id="nextPage">
				<button>上一页</button>
				1 / 1
				<button>下一页</button>
			</div>
		</div>
		<div id="add">
			<div class="addGroup">
				<lable for="id">ID：</label>
				<input type="text" v-model="id"/>
			</div>
			<div class="addGroup">
				<lable for="name">课程名：</label>
				<input type="text" v-model="name"/>
			</div>
			<div class="addGroup">
				<lable for="grade">开始学期：</label>
				<input type="text" v-model="grade"/>
			</div>
			<div class="addGroup">
				<lable for="gradeEnd">结束学期：</label>
				<input type="text" v-model="gradeEnd"/>
			</div>
			<div class="addGroup">
				<lable for="time">课时：</label>
				<input type="text" v-model="time"/>
			</div>
			<button @click="add">添加</button>
		</div>
	</div>
`,
	data(){
		return {
			errorMessage: '',
			successMessage: '',
			study: [
				{id: 1, name: '语文', grade: 1, gradeEnd: 3, time: 192},
				{id: 2, name: '数学', grade: 1, gradeEnd: 3, time: 192},
				{id: 3, name: '英语', grade: 1, gradeEnd: 3, time: 192},
				{id: 4, name: '政治', grade: 1, gradeEnd: 3, time: 192},
				{id: 5, name: '历史', grade: 1, gradeEnd: 3, time: 192},
				{id: 6, name: '生物', grade: 1, gradeEnd: 2, time: 128},
				{id: 7, name: '地理', grade: 1, gradeEnd: 2, time: 128},
				{id: 8, name: '物理', grade: 2, gradeEnd: 3, time: 128},
				{id: 9, name: '化学', grade: 3, gradeEnd: 3, time: 64},
			]
		}
	},
	methods: {
		add() {
			setTimeout(() => {
				if (this.id && this.name && this.grade && this.time) {
					this.study.push({
						id: this.id,
						name: this.name,
						grade: this.grade,
						gradeEnd: this.gradeEnd,
						time: this.time
					});
					alert("添加成功");
				} else {
					alert("请输入完整信息");
				}
			}, 1000); // 模拟异步操作
		},
		del(i) {
			this.study.splice(i, 1);
		},
	}
}